<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="./js/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" href="./css/bootstrap-theme.min.css">
<script src="./js/bootstrap.min.js"></script>

<title></title>
<script>
            $(document).ready(function() {                        

            	var idOdv = "1"; // Obtener de una configuración, en cada odv
            	$.get("http://localhost:8080/tpads-cpr-server/ListarRemitosAClientesService",
                		{odv:idOdv}, 
                		function(responseText) { 
                			// alert(responseText);
                			loadResultsTable(responseText);
                });            
            });
            
            function loadResultsTable(data) {
                var tbl_body = "";
                $.each(data, function() {
                    var tbl_row = "";
                    $.each(this, function(k , v) {
                        if (isLinkUrl(v)) {
                        	tbl_row += "<td><a href=" + v + ">" + "Ver" +"</a></td>";
                        } else {
                        	tbl_row += "<td>"+v+"</td>";
                        }
                    });
                    tbl_body += "<div class='row'><tr>"+tbl_row+"</tr><div>";                 
                });
                $("#resultsTable tbody").html(tbl_body);
            }
            
            function isLinkUrl(value){
                return (value.substr(0, "http".length) == "http");
            }

    	</script>
</head>

<body>

	<ul class="nav nav-pills nav-stacked">
	  <li class="active"><a href="http://localhost:8080/tpads-odv-client/index.jsp">Back to Home</a></li>
    </ul>
	<div class="panel panel-default">
		<!-- Default panel contents -->
		<div class="panel-heading">Remitos a Clientes</div>
		<div class="panel-body"></div>

		<table class="table" id="resultsTable">
			<thead>
				<tr>
					<th>Número remito</th>
					<th>Cliente</th>
					<th>Link</th>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
	</div>
    
</body>
</html>